﻿using System;
using System.Threading.Tasks;
using NSwag;
using NSwag.CodeGeneration.TypeScript;

namespace NSwagCodeGen
{
    class Program
    {
        async static Task Main(string[] args)
        {

            var document = await OpenApiDocument.FromUrlAsync("http://localhost:5000/swagger/v1/swagger.json");

            var settings = new TypeScriptClientGeneratorSettings
            {
                ClassName = "{controller}Client",
            };

            var generator = new TypeScriptClientGenerator(document, settings);
            var code = generator.GenerateFile();
            using (var streamWriter = new System.IO.StreamWriter("output.ts"))
            {
                await streamWriter.WriteLineAsync(code);
            }
        }
    }
}
